package com.zygh.lz.controller.pc;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageInfo;
import com.zygh.lz.entity.EquipageType;
import com.zygh.lz.entity.query.EquipageQuery;
import com.zygh.lz.entity.vo.EquipageVO;
import com.zygh.lz.service.PoliceEquipmentService;
import com.zygh.lz.service.impl.EquipageTypeServiceImpl;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: zygh-transform
 * @description: 装备信息
 * @author: jhaol
 * @created: 2023/06/06 13:55
 */

@Slf4j
@Api(tags = "装备信息")
@RestController
@RequestMapping("/policeEquipment")
public class PoliceEquipmentController {
    @Resource
    private PoliceEquipmentService policeEquipmentService;

    @Resource
    private EquipageTypeServiceImpl equipageTypeService;

    @GetMapping()
    public ResultBean<PageInfo<EquipageVO>> getEquipmentList(EquipageQuery equipageQuery) {
        return ResultUtil.setOK("success", policeEquipmentService.getEquipmentList(equipageQuery));
    }

    @GetMapping("/getEquipageTypeList")
    public ResultBean<EquipageType> getEquipageTypeList() {
        List<EquipageType> equipageTypeList = equipageTypeService.list(Wrappers.<EquipageType>lambdaQuery().groupBy(EquipageType::getTypeName));
        return ResultUtil.setOK("success", equipageTypeList);
    }

}
